package com.hdax.dm.utils.response;

import lombok.Data;

/**
 * 代表公共响应格式
 */
@Data
public class CommonResponse<T> {
    private String success;
    private String errorCode;
    private String msg;
    private T data;

    /*失败响应*/
    public CommonResponse(String errorCode,String msg){
        this.errorCode=errorCode;
        this.msg=msg;

    }

    /*成功响应 只传数据*/
    public CommonResponse(T data){
        this.success="success";
        this.errorCode="0000";
        this.msg="";
        this.data=data;
    }

    /*成功响应 只传数据*/
    public CommonResponse(String errorCode){
        this.success="success";
        this.errorCode=errorCode;
        this.msg="";
        this.data=null;
    }

    /*成功响应 传数据及成功响应消息*/
    public CommonResponse(T data,String msg){
        this.success="success";
        this.errorCode="0000";
        this.msg=msg;
        this.data=data;
    }
}
